{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {},
   "outputs": [],
   "source": [
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n",
    "from scipy.stats import norm as gaussian\n",
    "from math import pi, cos, sin"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Average: \n",
      "[[1.99769378]\n",
      " [5.06983369]]\n",
      "Cov:\n",
      "[[4.8368161  3.91591442]\n",
      " [3.91591442 5.08151032]]\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAARAAAAD8CAYAAAC/+/tYAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3VuMZdl93/fvf9/3Ppc6devrTPdcSEmkJYuiWgwMOIKCKLYsJGDowAb9kAiwgXEA6ykJEBkMYCGGAcdIYOQhSEQlgoUAlmIEYETIgmVTgMM8JLCGEk0Oxdvc+1Zd13Pd971WHvapmupi9Uz36aqumq7/B2h01amqs1efPv3rtdf6r7XEWotSSi3COesGKKU+vjRAlFIL0wBRSi1MA0QptTANEKXUwjRAlFILO5EAEZHfEpFNEXnj0GO/LiJ3ReSb81+/fBLXUkqdHyfVA/knwC8d8/g/ttZ+Zv7rD07oWkqpc+JEAsRa+3Vg9ySeSyn18eGd8vP/qoj8Z8DrwH9prd07+g0i8hrwGkCn0/nZn/iJnzjlJimljvONb3xj21q7/iQ/IydVyi4iLwG/b639yfnnl4FtwAJ/H7hqrf2bH/Yct27dsq+//vqJtEcp9WRE5BvW2ltP8jOnNgtjrX1grW2stQb4TeBzp3UtpdTZOLUAEZGrhz79AvDGo75XKfXxdCJjICLyO8AvAGsicgf4e8AviMhnaG9h3gX+9klcSy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9Hm3T43vidom19jQaopS6ALQSVSm1MA0QpdTCzkWAnMeS+Ee1af61vysib4rI90XkLz+rNh1pw6+LyN1Dr80vn0U75m35pflr8aaI/NpZteMoEXlXRL49f33OZAZQRH5LRDYP1zeJyIqI/CsR+eH89+Vz0KbF3k/W2jP/BXyKtojlXwO3Dj3+EvDGOWvTp4F/C4TAy8BbgHsG7ft14L86B3937vw1eAUI5q/Np8+6XfO2vQusnXEbfh747OH3MfCPgF+bf/xrwH93Dtq00PvpXPRArLXftdZ+/6zbcdiHtOnzwO9aawtr7TvAm8Dnnm3rzpXPAW9aa9+21pbA79K+Rgqw1n4dODoD+Xngt+cf/zbwH5+DNi3kXATIR3hZRP5URP5vEfl3z7oxwHXg9qHP78wfOwu/KiLfmndJn2k3+JDz9HocZYF/KSLfmC+ZOC8uW2vvzz/eAC6fZWMOeeL30zMLEBH5moi8ccyvD/vfar8k/meA/wL4pyLSP+M2PTMf0b7/GXgV+Azt6/Q/nGljz6e/aK39LPBXgL8jIj9/1g06yrb3D+ehlmKh99NpLqZ7iD2HJfGLtAm4C7x46PMX5o+duMdtn4j8JvD7p9GGx/DMXo8nZa29O/99U0S+Qnu79fWzbRUAD0TkqrX2vohcBTbPukHW2gf7Hz/J++lc38Kc05L4rwJfFJFQRF6et+nfPOtGzN94+75AuzfLWfhj4JMi8rKIBMAXaV+jMyUiHRHp7X8M/CXO7jU66qvAr8w//hXgUYtSn5mF309nOUJ9aAT4C7T3zgXwAPjD+eP/CfAd4JvAnwD/0Vm3af61L9HOPHwf+Ctn9Jr978C3gW/RviGvnuHf3y8DP5i/Jl866/fTvE2v0M4I/dv5e+hM2gX8Du0tQTV/P/0tYBX4I+CHwNeAlXPQpoXeT1rKrpRa2Lm+hVFKnW8aIEqphWmAKKUWpgGilFqYBohSamEaIEqphWmAKKUW9v8DuJ+j1WZ9ZVEAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 288x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# generate many 2D (column) vectors\n",
    "X = gaussian.rvs(0,1,(2,1000))\n",
    "X[0,:] *= 3  # scale axis 0\n",
    "f = +pi/4    # rotate by f\n",
    "R = np.array([[cos(f),-sin(f)],\n",
    "           [sin(f), cos(f)]]) \n",
    "V = R.dot(X)\n",
    "V += np.array([[2],\n",
    "               [5]]) # shift with a vector\n",
    "# plot on square figure\n",
    "plt.figure(figsize=(4,4)); a=15; plt.xlim(-a,a); plt.ylim(-a,a)\n",
    "plt.plot(V[0,:],V[1,:], '.', alpha=0.1)\n",
    "\n",
    "# sample covariance matrix\n",
    "averages = np.mean(V, axis=1)\n",
    "avg = averages.reshape(averages.size,1)\n",
    "#avg = averages[:,np.newaxis] \n",
    "print (\"Average: \")\n",
    "print (avg)\n",
    "print (\"Cov:\")\n",
    "print (np.dot(V-avg, (V-avg).T) / (V[0,:].size-1))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "<h1><font color=\"darkblue\">Method of Least Squares</font></h1>"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The Idea\n",
    "\n",
    "- Fit a model to training set $\\big\\{ (x_i, y_i) \\big\\}$\n",
    "\n",
    "> Parameterized function $f(x;\\theta)$, where $\\theta$ can represent multiple parameters\n",
    "\n",
    "- Minimize the mean or sum of square errors or residuals (SSE, SSR, MSE, MSR?)\n",
    "\n",
    "> Residual   \n",
    ">$r_i(\\theta) = y_i - f(x_i;\\theta)$\n",
    ">\n",
    "> Estimation  \n",
    ">$\\displaystyle \\hat{\\theta} = \\arg\\min_{\\theta} \\sum_i \\big[y_i-f(x_i;\\theta)\\big]^2$\n",
    " \n",
    "- Optimization is simple for certain models"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The Simplest Case\n",
    "- Fitting a constant? Model with $f(x;\\mu)=\\mu$\n",
    "\n",
    ">$\\displaystyle C(\\mu) = \\sum_{i=1}^N \\big(y_i\\!-\\!\\mu\\big)^2$\n",
    "\n",
    "- Derivative $C'= dC \\big/ d\\mu$ vanishes at solution $\\hat{\\mu}$\n",
    "\n",
    ">$\\displaystyle C'(\\hat{\\mu}) = 0$\n",
    ">\n",
    ">$\\displaystyle 2\\sum_{i=1}^N \\big(y_i\\!-\\!\\hat{\\mu}\\big)(-1)=0$\n",
    ">\n",
    ">$\\displaystyle \\sum_{i=1}^N y_i - N \\hat{\\mu} = 0 $\n",
    ">\n",
    ">$\\displaystyle \\hat{\\mu} = \\frac{1}{N}\\sum_{i=1}^N y_i \\ \\ \\ \\ \\ $  -  average"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Heteroscedasticity\n",
    "- Same model with $f(x;\\mu)=\\mu$\n",
    "\n",
    ">$\\displaystyle C(\\mu) = \\sum_{i=1}^N \\frac{\\big(y_i\\!-\\!\\mu\\big)^2}{\\sigma_i^2} $\n",
    ">\n",
    "> with  $\\ w_i=1 \\big/ \\sigma_i^2$\n",
    ">\n",
    ">$\\displaystyle  C(\\mu) = \\sum_{i=1}^N w_i\\big(y_i\\!-\\!\\mu\\big)^2 $\n",
    "\n",
    "- Derivative $C'= dC \\big/ d\\mu$ vanishes at $\\hat{\\mu}$\n",
    "\n",
    ">$\\displaystyle C'(\\hat{\\mu}) = 0$\n",
    ">\n",
    ">$\\displaystyle 2\\sum_{i} w_i \\big(y_i\\!-\\!\\hat{\\mu}\\big)(-1)=0$\n",
    ">\n",
    ">$\\displaystyle \\sum_{i} w_i y_i - \\hat{\\mu}\\sum_{i} w_i  = 0 $\n",
    ">\n",
    ">$\\displaystyle \\hat{\\mu} = \\frac{\\sum w_i y_i}{\\sum w_i} \\ \\ \\ \\ \\ \\ $ - weighted average"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Simple Fitting\n",
    "- A linear model with $\\boldsymbol{\\theta}=(a,b)^T$ parametrization $f(x;\\boldsymbol{\\theta}) = a + b\\,x$\n",
    "  \n",
    ">$\\displaystyle \\hat{\\boldsymbol\\theta} = \\arg\\min \\sum_i \\big[y_i-(a + b\\,x_i)\\big]^2$\n",
    "\n",
    "- Derivatives w.r.t. $a$ and $b$ should vanish\n",
    "\n",
    "> We have 2 variables and 2 equations\n",
    "\n",
    "> Quadratic becomes linear $\\rightarrow$ analytic solution!"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Linear Regression\n",
    "- A linear combination of known $\\phi_k(\\cdot)$ functions (basis functions)\n",
    "\n",
    ">$\\displaystyle f(x;\\boldsymbol{\\beta}) = \\sum_{k=1}^K \\beta_k\\, \\phi_k(x) $\n",
    "\n",
    "> It's a dot product\n",
    "\n",
    ">$\\displaystyle f(x;\\boldsymbol{\\beta}) = \\boldsymbol\\beta^T \\boldsymbol\\phi(x)$ \n",
    "\n",
    ">with $\\boldsymbol{\\beta}=(\\beta_1,\\dots,\\beta_K)^T$\n",
    "\n",
    "\n",
    "- Linear in $\\boldsymbol{\\beta}$, cost function is quadratic\n",
    "\n",
    ">$\\displaystyle C = \\sum_{i=1}^N \\left\\{ y_i - \\sum_{k=1}^K \\beta_k\\, \\phi_k(x_i) \\right\\}^2$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "- Introducing matrix $X$ with components\n",
    "\n",
    ">$\\displaystyle X_{ik} = \\phi_k(x_i) $\n",
    "\n",
    "- Linear in $\\boldsymbol{\\beta}$, cost function is quadratic\n",
    "\n",
    ">$\\displaystyle C = \\sum_{i=1}^N \\left\\{ y_i - \\sum_{k=1}^K X_{ik}\\beta_k\\right\\}^2$\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Minimization\n",
    "\n",
    "- Partial derivatives\n",
    "  \n",
    "\n",
    ">$\\displaystyle \\frac{\\partial{}C}{\\partial{}\\beta_l} = 2\\sum_i \\Big\\{ \\dots\\Big\\} \n",
    "\\left[ -\\frac{\\partial f(x_i;\\boldsymbol{\\beta})}{\\partial \\beta_l} \\right]$\n",
    "\n",
    "> and\n",
    "\n",
    ">$\\displaystyle \\frac{\\partial f(x_i;\\boldsymbol{\\beta})}{\\partial \\beta_l} =\\sum_k \\frac{\\partial{}\\beta_k}{\\partial{}\\beta_l}\\,\\phi_k(x_i) = \\phi_l(x_i) = X_{il}$\n",
    "\n",
    "> **Note:** $\\partial{}\\beta_k \\big/ \\partial{}\\beta_l=\\delta_{kl}$ Kronecker delta"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Detour: The Kronecker Delta\n",
    "\n",
    "- Definition\n",
    "\n",
    ">$ \\delta_{kl} = \\left\\{ \\begin{array}{ll}\n",
    "         1 & \\mbox{if $k=l$}\\\\\n",
    "         0 & \\mbox{if $k\\neq{}l$}\\end{array} \\right.  $\n",
    "         \n",
    "- Useful to remember\n",
    "\n",
    ">$ \\displaystyle \\sum_l \\delta_{kl}\\,a_l = a_k$\n",
    "\n",
    "> Cf. identity matrix:\n",
    ">$ I\\, \\boldsymbol{a} = \\boldsymbol{a}$"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Result\n",
    "\n",
    "- At the optimum we have\n",
    "\n",
    "\n",
    ">$\\displaystyle \\sum_i \\left\\{ y_i - \\sum_{k} \\hat\\beta_k\\, \\phi_k(x_i) \\right\\}\\, \\phi_l(x_i)  = 0$\n",
    "\n",
    ">$\\displaystyle \\sum_i \\left\\{ y_i - \\sum_{k} X_{ik}\\hat\\beta_k\\ \\right\\}\\, X_{il}  = 0$\n",
    "\n",
    ">$\\displaystyle \\sum_i X_{il} y_i  - \\sum_i \\sum_k  X_{il} X_{ik} \\hat{\\beta}_k = 0$\n",
    "\n",
    ">$\\displaystyle \\sum_i  X_{il} y_i = \\sum_k \\left(\\sum_i X_{il} X_{ik}\\right) \\hat{\\beta}_k$\n",
    "\n",
    "- I.e.,\n",
    "\n",
    ">$\\displaystyle X^T y = X^T X \\hat{\\beta} $\n",
    "\n",
    ">$\\displaystyle \\hat\\beta = (X^T X)^{-1} X^T y = X^+ y$\n",
    "\n",
    "- See **Moore-Penrose pseudoinverse**, **generalized inverse**\n",
    "\n",
    "- See also **Singular Value Decomposition**"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Hat matrix\n",
    "\n",
    "- Looking at the definition of $X$ we see that the model at $\\hat{\\beta}$ predicts $\\hat{y}_i$ values\n",
    "\n",
    ">$\\displaystyle \\hat{y} = X\\,\\hat\\beta = X\\,(X^T X)^{-1} X^T y $\n",
    "\n",
    "> which is\n",
    "\n",
    ">$\\displaystyle \\hat{y}  = H\\,y\\ \\ \\ $\n",
    "> with \n",
    ">$\\ \\ \\displaystyle {H} = X\\,(X^T X)^{-1} X^T$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 13,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGL1JREFUeJzt3X+wnHV96PH3xwRoi0A6JlUE0njRcQa9hcKRwal23EotUC8xrT/ijAr9MfGeytiWy+RKvcnVOHc65AKO9gc0rc4o9Qq5VjCVoMJwOtg7I+aEy49QoE2pHZIyNdKKOnjF2M/949ltdjd79uye3Wd3n933a2Zn93me79n9Pln4fvb7OzITSZIaXjDuDEiSJouBQZLUwsAgSWphYJAktTAwSJJaGBgkSS0MDJKkFgYGSVILA4MkqcXqcWdgJdauXZsbNmwYdzYkqVL279//rcxct1y6SgaGDRs2sLi4OO5sSFKlRMQ/9pLOpiRJUgsDgySphYFBktTCwCBJamFgkCS1mInAsHMnLCy0nltYgMsu63x+587R5U2SJs1MBIbXvAbe/vZjQWBhoTi++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P/wz4IIR5a0svXyPlZKZ32lU+TNzL3BCRKwdc7a6iogTKArQz2Tm5zskqdz3tNw9VfF7asjMbwMLwCVtl4ZW5lU1MOwDXhERL4uIEyk6Wva0pdkDXFF//Vbg3qz3ykyoZe+prV33coq20yrbA7ynPurlIuDZ7GFr10kWES9ptOtGxIUU/49N7A+Sel4/ATyWmTcukaxS31Mv91TB72ldRKypv/5x4BeBx9uSDa3MW73SjI5TZh6NiKuAL1OM5vlkZj4aETuAxczcQ/Efxi0RcZCis3Dz+HK8vB7v6f0RcTlwlOKerhxbhnsQEZ+lGP2xNiIOAf+dotOMzLwZ2Esx4uUg8Bzwa+PJae96uKe3AvMRcRT4PrB5wn+Q/BzwbuCRevs1wO8B66Gy31Mv91S17+l04FMRsYoiiO3OzC+WVeY581mS1KKqTUmSpJIYGCRJLQwMkqQWBgZJUgsDgySphYFBktTCwCBJamFgkCS1+P9QHZK3ZkKMKQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# generate sample with error\n",
    "x = 3 * np.random.rand(50) # between 0 and 3\n",
    "e = 1 * np.random.randn(x.size) # noise\n",
    "#y = (0.1*x**3 + 0.5*x**2 + 2*x + 1) + e;  plot(x,y,'bo');\n",
    "y = 10*np.cos(x+1) + e;  plt.plot(x,y,'bx');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2.71849848, -5.6998836 ])"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4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0KpNRdc+pol/3QkLfaZ5tBS6Jsl5eBzzj88uw55KZnVzs1zWzswn/j2X2B0lU11uAR9z9s1WK5ep7SnJOOfyeTjCz46PHS4E3AT+qKNa2a14u93x29yNm9gHgHkI2z63uvtfM1gE73X0r4T+M281yrb0IAAAAqUlEQVRsH2GwcHX3alxfwnP6oJldCBwhnNN7u1bhBMzsq4Tsj2UW1tT6OGHQDHffAGwjZLzsAw4D7+tOTZNLcE7vBCbN7AjwHLA64z9Ifhe4GHg46r8G+CgwArn9npKcU96+p1OA28xskBDENrv7nWld8zTzWUREyuS1K0lERFKiwCAiImUUGEREpIwCg4iIlFFgEBGRMgoMIiJSRoFBRETKKDCIiEiZ/w+rq3u11x92mwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# linear model f(x) = b0 + b1 x\n",
    "X = np.ones((x.size,2));\n",
    "X[:,1] = x\n",
    "\n",
    "Xpinv = np.dot(np.linalg.inv(np.dot(X.T,X)),X.T)\n",
    "bHat = np.dot(Xpinv,y)\n",
    "yHat = np.dot(X,bHat)\n",
    "\n",
    "plt.plot(x,y,'bx'); plt.plot(x,yHat,'ro'); bHat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "array([ 2.71849848, -5.6998836 ])"
      ]
     },
     "execution_count": 20,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3X+UnFWd5/H3tzsJmwYB7fB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ep7SnJOOfyeTjCz46PHS4E3AT+qKNa2a14u93x29yNm9gHgHkI2z63uvtfM1gE73X0r4T+M281yrb0IAAAAqUlEQVRsH2GwcHX3alxfwnP6oJldCBwhnNN7u1bhBMzsq4Tsj2UW1tT6OGHQDHffAGwjZLzsAw4D7+tOTZNLcE7vBCbN7AjwHLA64z9Ifhe4GHg46r8G+CgwArn9npKcU96+p1OA28xskBDENrv7nWld8zTzWUREyuS1K0lERFKiwCAiImUUGEREpIwCg4iIlFFgEBGRMgoMIiJSRoFBRETKKDCIiEiZ/w+rq3u11x92mwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# same using methods\n",
    "Xpinv = np.linalg.inv(X.T.dot(X)).dot(X.T)\n",
    "bHat = Xpinv.dot(y)\n",
    "yHat = X.dot(bHat)\n",
    "\n",
    "plt.plot(x,y,'bx'); plt.plot(x,yHat,'ro'); bHat"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3X+UnFWd5/H3tzsJmwYB7fBLtLsdltmz6s4wkHDkzIyHVvwBOsTM+CN7ih86O6eh0RXXncOKMYhhGSXrjyMzQswRPEj3GrM6xCwEESbt6uysmIQJkIiMkUnzYxhNouIwYWRCf/eP+xRdVf1U1VM/nqrnqfq8zqlTVU/drrpPCp5v3Xu/915zd0RERIoGul0BERHJFgUGEREpo8AgIiJlFBhERKSMAoOIiJRRYBARkTIKDCIiUkaBQUREyigwiI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nWld8zTzWUREyuS1K0lERFKiwCAiImUUGEREpIwCg4iIlFFgEBGRMgoMIiJSRoFBRETKKDCIiEiZ/w+rq3u11x92mwAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# same again with pinv() and the Hat matrix\n",
    "H = X.dot(np.linalg.pinv(X)) \n",
    "yHat = H.dot(y)\n",
    "\n",
    "plt.plot(x,y,'bx'); plt.plot(x,yHat,'ro');"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAHuxJREFUeJzt3X2QHPV95/H3d7WSzPIgpSRh86QVMVTKYMcyXlFQMS42YBvwHYodHuQMMth3t7BAHQ726UC61flIrV3SWbjsOIeyxBDDbmwU2wSBhTFEm7Lv6oy1YB5WweSEkQQUCYsCwniJ5dV+74+eYWdme2Z6dqZnumc+r6qume75zcyvd6T+9u/Z3B0REZGcjmZnQEREkkWBQURECigwiIhIAQUGEREpoMAgIiIFFBhERKSAAoOIiBRQYBARkQIKDCIiUqCz2RmYi6VLl/qKFSuanQ0RkVR57LHHXnX3ZZXSpTIwrFixgrGxsWZnQ0QkVcxsX5R0qkoSEZECCgwiIlJAgUFERAooMIiISAEFBhERKdA+gWFkBFasgI6O4HFkpNk5EhFJpFR2V63ayAj09cHkZLC/b1+wD5DJNC9fIiIJ1B4lhg0bZoJCzuRkcFxERAq0R2DYv7+64yIibaw9AsPy5dUdFxFpY+0RGAYHoaur8FhXV3BcREQKtEdgyGRgaAi6u8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gbkmxevwk84+63lkiWqt8pyjml8HdaZmaLs8+PAD4C/KIoWd2ueZ1zzWgzufuUmV0PPETQm+cOd99tZrcAY+6+neAfxt1mtoegsXBN83JcWcRz+s9mdjEwRXBOVzUtwxGY2bcJen8sNbMXgf9O0GiGu28FdhD0eNkDTAKfaU5Oo4twTpcA/WY2BbwFrEn4DckfAGuBp7P11wDrgeWQ2t8pyjml7Xc6DviWmc0jCGLb3P2BuK55GvksIiIF0lqVJCIiMVFgEBGRAgoMIiJSQIFBREQKKDCIiEgBBQYRESmgwCAiIgUUGEREpMD/B0zgDzRmN+2UAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# linear model f(x) = b0 + b1 x + b2 * x^2\n",
    "X = np.ones((x.size,3));\n",
    "X[:,1] = x # partials with respect to b1\n",
    "X[:,2] = x*x # with respect to b2\n",
    "\n",
    "# sames as before\n",
    "bHatQ = np.linalg.pinv(X).dot(y)\n",
    "yHatQ = X.dot(bHatQ)\n",
    "\n",
    "# or like this\n",
    "H = np.dot(X,np.linalg.pinv(X))\n",
    "yHatQ = np.dot(H,y)\n",
    "\n",
    "plt.plot(x,y,'bx'); plt.plot(x,yHatQ,'ro');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Exercise\n",
    "\n",
    "0. Fit to the same data the function $f(x;\\beta_0,\\beta_1) = \\beta_0\\sin(x) + \\beta_1\\cos(x)$\n",
    "\n",
    "0. Evaluate the best fit on a grid of $x$ values in $[-1, 4]$"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cG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JNsYsMMbM8uR5/CrwgSXAUOB7pwvxJGNMMPACMBjoBlxpjOnmbFUe9xZwntNFeFkBMMZa2w04Cbg9AP495wFnWmt7A32A84wxJzlckzeMBpZ5+iR+FfjW2mXW2hVO1+EFA4DV1tq11tp8YBpwicM1eZS19ntgp9N1eJO1drO1dv6h3/fiCoSWzlblWdYl59Dd0EM3v77QaIyJAy4AXvP0ufwq8ANIS2BDifsb8fMgCHTGmLZAX+BXZyvxvEPdGwuBbcDX1lp/f8/PAPcBRZ4+Ua0LfGPMHGPMknJuft3ClcBljKkDfAjcZa3NdroeT7PWFlpr+wBxwABjTA+na/IUY8yFwDZrbbo3zhfijZPUJGvtWU7X4AM2Aa1K3I879Jj4GWNMKK6wf89aO9PperzJWrvbGJOC69qNv16sPwW42BhzPhABxBhjplprr/HEyWpdC18ASAU6GmNOMMaEAcOBTx2uSWqYMcYArwPLrLVPO12PNxhjGhtj6h36PRI4G1jubFWeY60da62Ns9a2xfX/8VxPhT34WeAbYy41xmwEBgKfG2NmO12TJ1hrC4A7gNm4LuQlW2szna3Ks4wx/wV+ATobYzYaY250uiYvOAUYAZxpjFl46Ha+00V5WHMgxRizGFfD5mtrrUeHKgYSzbQVEQkQftXCFxGRY1Pgi4gECAW+iEiAUOCLiAQIBb6ISIBQ4IuIBAgFvohIgFDgi4gEiP8H/nu6In1oNS8AAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# exercise\n",
    "x = 3 * np.random.rand(50) # between 0 and 3\n",
    "e = 1 * np.random.randn(x.size) # noise\n",
    "y = 10*np.cos(x+1) + e;  \n",
    "plt.plot(x,y,'bx');\n",
    "\n",
    "X= np.ones((x.size,2))\n",
    "X[:,0]= np.sin(x)\n",
    "X[:,1]= np.cos(x)\n",
    "\n",
    "xx = np.linspace(-1,4,100)\n",
    "XX= np.ones((xx.size,2))\n",
    "XX[:,0]= np.sin(xx)\n",
    "XX[:,1]= np.cos(xx)\n",
    "\n",
    "bhat = np.linalg.pinv(X).dot(y)\n",
    "yhat = XX.dot(bhat)\n",
    "\n",
    "plt.plot(xx,yhat)\n",
    "plt.show()\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Excercise\n",
    "\n",
    "\n",
    "0. Fit a 3rd order polynomial to the same data\n",
    "\n",
    "0. Evaluate on a grid of 1000 equally-spaced points in $[-1,4]$\n",
    "\n",
    "0. Plot the best (sin+cos) and (3rd order) results over each other"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAIABJREFUeJzt3XlYVNUfx/H3GfZF3MAV911RSXFf0dwtNctcyxYt03ZLzbTcysz8ZWVWapaaprmWa5mYormg4r7vuKEoyiYInN8fA4gJCjLDBeb7ep55YGbunPsdrM+cOffcc5XWGiGEEHmfyegChBBCZA8JfCGEsBES+EIIYSMk8IUQwkZI4AshhI2QwBdCCBshgS+EEDZCAl8IIWyEBL4QQtgIe6MLSM3T01OXLVvW6DKEECJX2bVr1zWttdfDtstRgV+2bFmCgoKMLkMIIXIVpdTZjGwnQzpCCGEjJPCFEMJGSOALIYSNyFFj+EKInOHOnTuEhIRw+/Zto0sRqTg7O+Pt7Y2Dg8MjvV4CXwhxn5CQEPLly0fZsmVRShldjgC01oSFhRESEkK5cuUeqQ0Z0hFC3Of27dsULlxYwj4HUUpRuHDhLH3rksAXQqRJwj7nyeq/Sd4I/OunYc1wSLhjdCVCCJFj5Y3Av3oUtk+HPXONrkQIYUUvv/wyhw4de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JU4AMHgKeATUYXYk1KKTtgGtABqA70UkpVN7Yqq/sJaG90EdksHnhXa10daAgMtoF/51iglda6NuALtFdKNTS4puzwJnDY2jvJU4GvtT6stT5qdB3ZoD5wQmt9SmsdB/wKdDG4JqvSWm8CrhtdR3bSWl/SWu9O+j0CcyCUNLYq69JmkUl3HZJuefpAo1LKG+gEzLT2vvJU4NuQksD5VPdDyONBYOuUUmWBx4DtxlZifUnDG8FAKPCX1jqvv+cvgfeBRGvvKNcFvlJqvVLqQBq3PN3DFbZLKeUOLAHe0lrfMroea9NaJ2itfQFvoL5SysfomqxFKdUZCNVa78qO/dlnx04sSWv9uNE15AAXgFKp7nsnPSbyGKWUA+aw/0VrvdToerKT1jpcKRWA+dhNXj1Y3wR4UinVEXAGPJRS87TWfa2xs1zXwxcA7AQqKaXKKaUcgZ7A7wbXJCxMKaWAWcBhrfUUo+vJDkopL6VUgaTfXYA2wBFjq7IerfUIrbW31ros5v+PN1gr7CGPBb5SqptSKgRoBKxSSq0zuiZr0FrHA0OAdZgP5C3SWh80tirrUkotAP4FqiilQpRSLxldUzZoAvQDWimlgpNuHY0uysqKAwFKqX2YOzZ/aa2tOlXRlsiZtkIIYSPyVA9fCCFE+iTwhRDCRkjgCyGEjZDAF0IIGyGBL4QQNkICXwghbIQEvhBC2AgJfCGEsBH/B37idUWOq07uAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "X3 = np.ones((x.size,3))\n",
    "X3[:,1] = x**1\n",
    "X3[:,2] = x**2\n",
    "\n",
    "# Evaluate on a grid of 1000 equally-spaced points in [−1,4]\n",
    "xx3 = np.linspace(-1,4,1000)\n",
    "XX3 = np.ones((xx3.size,3))\n",
    "XX3[:,1] = xx3**1\n",
    "XX3[:,2] = xx3**2\n",
    "\n",
    "bhat3 = np.linalg.pinv(X3).dot(y)\n",
    "yhat3 = XX3.dot(bhat3)\n",
    "\n",
    "# Plot the best (sin+cos) and 3rd order result\n",
    "plt.plot(x,y,'bx');\n",
    "plt.plot(xx,yhat,label='sin(x)+cos(x)')\n",
    "plt.plot(xx3,yhat3,label='Third Order')\n",
    "plt.legend();\n",
    "plt.show();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "\n",
    "### Heteroscedastic error\n",
    "\n",
    "- Simple modification\n",
    "\n",
    ">$\\displaystyle C = \\sum_{i=1}^N w_i \\left\\{ y_i - \\sum_{k=1}^K X_{ik}\\beta_k\\right\\}^2$\n",
    "\n",
    "\n",
    "> yields\n",
    "\n",
    ">$\\displaystyle \\sum_i w_i \\left\\{ y_i - \\sum_{k} X_{ik} \\hat\\beta_k\\ \\right\\}\\, X_{il}  = 0$\n",
    "\n",
    "\n",
    ">$\\displaystyle \\sum_i  X_{il} w_i y_i = \\sum_k \\left(\\sum_i X_{il} w_i X_{ik}\\right) \\hat{\\beta}_k$\n",
    "\n",
    "\n",
    "- Diagonal weight matrix $W$\n",
    "\n",
    ">$\\displaystyle X^T W y = X^T W X \\hat{\\beta} $\n",
    "\n",
    ">$\\displaystyle \\hat\\beta = (X^T W X)^{-1} X^T W y $\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem with Linear Regression (Over-fit)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAGDFJREFUeJzt3X+Q3Hddx/HXy6atHaitQwKUtjFVO4zo2JbeZWBUhrOIpSOkqTXGkQL+mEyDjNXaiVQmV6yjlSvgCDhh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Z1grnE+jPp+I+L+IuFzSRZI22v6pst5rkhLDSUnZb8wXpY/1LGN7jaTzJD0zlugGt+L5RMQzEfHd9PBDkq4cU2xlKfIZNkZEfKtT/Y+IA5LOtL224rD6sn2mkovoJyPirh5FGvX5rHQ+Tft8OiLiPyXNS7q666mRXd8mKTEcknSp7Utsn6Wk82V/V5n9kt6c3r9e0sFIe2pqaMXz6WrffYOSdtQm2y/pTenol1dIejYinq46qNWy/eJOG6/tjUr+3mr5RSSN88OSjkXEe/sUa8znU+R8Gvb5rLN9fnr/HEm/IOnxrmIju76tWW2gdRMRi7bfJukLSkb0fCQiHrV9u6SFiNiv5Bfl47aPK+k03FpdxMsreD6/a/sNkhaVnM9bKgu4ANufUjISZK3tE5JuU9KJpoj4oKQDSka+HJf0HUm/UU2kxRQ4n+slbbe9KOl/JG2t8ReRn5F0g6RH0nZsSfojSeulRn4+Rc6nSZ/PBZI+avsMJQlsb0TcU9b1jZnPAICcSWpKAgCMAIkBAJBDYgAA5JAYAAA5JAYAQA6JAQCQQ2IAAOSQGAAAOf8P2LMzEMxa38cAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# generate sample with error\n",
    "x = 3 * np.random.rand(50) # between 0 and 3\n",
    "e = 1 * np.random.randn(x.size) # noise\n",
    "y = 10*np.cos(x+1) + e;  \n",
    "plt.plot(x,y,'bx');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Fit and predict using linear regression with different order of polynomials"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD8CAYAAABzTgP2AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2Z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ZCTFixfH29ubhg0bAnD79m3dl3nVqlW5fft2jm2vUqUKH330EStXrmTv3r25+2XkwLVr1+jUqROXL19m+vTpVKtW7bnLfBperh5DBi3GgGVj2D4WYsIL2xqFosiQkpLCqVOnGDlyJKdPn8bMzIzvv//+ucsMDw+nefPmnDp1imbNmvHxxzn32CdNmsSYMWMeG5fftm0blStXpkGDBo/lmTJlChcuXCAgIIB79+4xdepUAD799FOio6NxcXFh7ty5uLq6YmhoiL29PePHj6ddu3a0b98eFxcXDA0NHytX07QnrvJZsGABHTt2xNLS8kmPI1dUr16dP//8k8uXL7Ns2TKdYyooXr4eA4ChEfT4GX5qBZtGwMAtYPD4H4RCUZjk9GafX1haWmJpaUmTJk2A9OGdRx2DhYUF165d092Hh4djYWGBhYUF+/bt0wtv06YNFSpUoESJEvTo0QOAN998k8WLF+uVZWlpSUpKCjExMVSoUIHjx4/j5eXFuHHjiI6OxsDAAFNTU65fv87WrVvx9vYmISGB2NhY3nrrLVauXKl7wzcxMWHw4MG6nkbp0qVZunQpkD6nam1tjY2NDQBDhw7VDZv997//1X2xV6lShZs3b2Jubs7NmzepXLlyjm0/evQoBw8eZMGCBcTHx5OUlETJkiWf26lWq1YNR0dHDh48iKdnwY1uvFQ9hpjEGAJuBaTflLeBDlMh9CAcnVe4hikURYSqVatSvXp1Ll68CICPjw9169bVS9OlSxeWL1+OiHDs2DHKlCmDubk5r7/+Ort37yYqKoqoqCh2797N66+/jqZpvPHGGzqnkbnMLl266FYveXl54e7ujqZpHDx4kNDQUEJDQ/nwww/573//y+jRo5kyZQrh4eGEhoayZs0a3N3dWblyJYBurF9E2Lx5M46OjkD6KqukpCQAfv31V1599VVKly4NwJ07d4D01U8bN26kX79+j9m1bNkyunbtmmPbV61axdWrVwkNDWXGjBkMHDjwmZ1CeHg4Dx48ANJXVB06dIjatWs/U1nPTG5mqIva9ayrksbtHyeNVjaSs3fPpgekpYmseUvkqwoiN848U5kKRV5SFFYlnT59Who0aCBOTk7StWtXuXfvnix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WCHEQyAQ2SikvuU0s0X5dr4nhRrMOCJRSdgc28ueehNI49mO69EAPYBHwQyPHUy8hhCvwLfCslLKwseO5FvXUpUlsGymlQUrZEwgAwoQQXa25/us1MaQBNfeaA6pfq7OMEEIHeAA5VonuytRbFylljpSyovrpciDUSrE1NHO2m82TUhaeHwqQUv4M2AkhvBo5rEsSQthhaki/klJ+V0eRJrNd6qtLU9s2Usp8IBoYedFbFm2/rtfEsBcIEUIECSHsMU3OrL2ozFrg4erfJwBRsnomx8bUW5eLxnvvwjS22hStBR6qPgqmL1Agpcxo7KCulBDC5/x4rxAiDNP/mS3udFAd58fACSnle5co1iS2izl1aQrbRgjRUgjhWf27EzAcOHlRMYu2X7qGWpAtkVLqhRDPAL9iOqrnEynlMSHEXCBGSrkW0x/QCiFEHKaJxHsbL+JLM7MuM4QQdwF6THWZ3GgBX4YQ4mtMR4V4CSFSgdcwTawhpVwC/IzpCJg4oBR4pHEivTwz6jEBmCqE0ANlwL02utMB0B94EDhSPaYN8A+gDTSt7YJ5dWkK28YX+FwIocWUuCKllOut2X6pM58VRVGUWq7XoSRFURTlKqnEoCiKotSiEoOiKIpSi0oMiqIoSi0qMSiKoii1qMSgKIqi1KISg6IoilKLSgyKoihKLf8PAcMfXakStvgAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "def ser(x, n):\n",
    "    X = np.ones( (x.size, n+1) )\n",
    "    for i in range(1, n+1):\n",
    "        #X[:,i] = np.sin(i * x)\n",
    "        X[:,i] = x**i\n",
    "    return X    \n",
    "\n",
    "xx = np.linspace(0, 3, 100) \n",
    "\n",
    "for n in range(1,6):\n",
    "    X = ser(x, n)  \n",
    "    b = np.linalg.pinv(X).dot(y)\n",
    "    mse = sum(np.square(y-X.dot(b)))/(x.size-b.size)\n",
    "    yhat = ser(xx,n).dot(b) \n",
    "    plt.plot(xx, yhat, label=mse);  \n",
    "    \n",
    "plt.plot(x,y,'bx');  \n",
    "plt.legend();\n",
    "plt.show();"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Problem with Linear Regression (Outliers)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Generate Outliers"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAD0VJREFUeJzt3X+IHOd9x/HPx5ZdcFNapzpU1ZF9aRABpTSOuxIODcGL01bxH1HcJkImpHJpuaLaNCkF4SZICTKGIhoH+kvhWouoRbFzJHGjpkpcxz1wC6l7K6PYJ4vUqhslEoq1jsF2UUlQ/O0fM7L2Tnt3e7czOzfzvF+w7M4z43mex2N/mHv22XkcEQIANN9VVTcAADAaBD4AJILAB4BEEPgAkAgCHwASQeADQCIIfABIBIEPAIkg8AEgEWuqbkCvtWvXxvj4eNXNAIBaOXbs2EsRMbbUcasq8MfHx9XpdKpuBgDUiu3TgxzHkA4AJILAB4BEEPgAkAgCHwASQeADQCKGDnzbG2xP237O9gnbH8vL32z7cdvP5+/XD99cACjI4cPS+Lh01VXZ++HDVbeodEXc4V+U9CcRsUnSrZLusb1J0n2SnoiIjZKeyLcBoHqHD0sTE9Lp01JE9j4x0fjQHzrwI+JcRDydf35N0klJN0jaJulQftghSR8cti4AKMQnPylduDC37MKFrLzBCh3Dtz0u6V2SnpK0LiLO5bt+IGndAv/MhO2O7U632y2yOQDQ3/e+t7zyhigs8G2/SdKXJX08Il7t3RfZSul9V0uPiMmIaEVEa2xsyV8GA8DwbrxxeeUN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AYbW8ZoP0ra7XbTnKWtO2UBFx0fa9kh5TNqvlYEScsL1PUicijii7mP9g+5SyL9R2VNfiwQ3Ytz+y/QFJF5X17e7KGrwMth9WNvNhbb4U5qckXSNJEfE5SUeVzfo4JemCpN+tpqXLM0C/PiRpl+2Lkv5P0o6a3Hz8mqSPSnrW9vG87BOSbpTqfc00WN/qet0Gxi9tASARdRnSAQAMicAHgEQQ+ACQCAIfABJB4ANAIgh8AEgEgQ8AiSDwASAR/w+vuxPlbYwQKQAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# Add an outlier (2.5, 20) to the original dataset\n",
    "x = 3 * np.random.rand(10) # between 0 and 3\n",
    "e = 1 * np.random.randn(x.size) # noise\n",
    "y = 10*np.cos(x+1) + e;  \n",
    "plt.plot(x,y,'bx');\n",
    "xold = x;\n",
    "yold = y;\n",
    "x = np.hstack((x,2.5))\n",
    "y = np.hstack((y,20))\n",
    "plt.plot(2.5,20,'ro');"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "#### Fit the new dataset (with outliers)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD8CAYAAAB0IB+mAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvnQurowAAH/dJREFUeJzt3X98VPWd7/HXh5+R3z+SjAhiUPmRQCloQFGDJCRq++hWu926bV211/aya3/Q9nbrteulsnq95Vrbu9a2Wm5LtV5a69auWrdWEwwV9ioSkFpNQH4YMRYmIQjhVyAh3/3jnAlJyI9JZiYzk/N+Ph55zMw5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AS4M0u5n8UeB4w4HJgU7LbHMO+LAGeS3Y7o9iPScAl/vPRwNud/PtKi+8lyn1Jl+/FgFH+86HAJuDyDsskLMPS7Qh/IbDLObfHOXcKeAK4vsMy1wOP+c9/Ayy11By/OZp9SQvOuZeB7q6kvh74hfO8Cowzs0n907reiWJf0oJzbp9zbqv//AhQBUzusFhafC9R7kta8D/ro/7Lof5PxxOpCcuwdAv8ycB7bV7XcPYX37qMc64ZOAxM7JfW9U40+wLwSf/P7d+Y2fn907S4i3Zf08Ui/0/y581sdrIb0xO/S2A+3tFkW2n3vXSzL5Am34uZDfaHnakFSp1zXX4v8c6wdAv8oPkdkOOcmwuUcua3viTPVrzL2D8MPAQ8neT2dMvMRgFPAV9znQxPnk562Je0+V6cc6eddzfAKcBCM5vTX9tOt8B/H2h7lDvFn9bpMmY2BBgL1PdL63qnx31xztU7b6hpgJ8Cl/ZT2+Itmu8tLTjnGiJ/kjvnfg8MNbPMJDerU2Y2FC8g1zrnftvJImnzvfS0L+n0vUQ45w4B5cB1HWYlLMPSLfA3A9PNbJqZDcM7ofFsh2WeBW71n/8N8JLzz36kmB73pUN/6sfx+i7T0bPALX5VyOXAYefcvmQ3qi/M7NxIf6qZLcT7P5RyBxR+G38GVDnnvt/FYmnxvUSzL2n0vWSZ2Tj/+TlACbC9w2IJy7BYb2Ler5xzzWb2ZeAFvCqXNc65t8zsHqDCOfcs3j+Mx81sF97Jt08nr8Vdi3JflpvZx4FmvH35XNIa3A0z+xVelUSmecNl3413Mgrn3CPA7/EqQnYBx4H/kpyW9iyKffkb4HYzawZOAJ9O0QOKK4GbgT/7/cUA/wRMhbT7XqLZl3T5XiYBj5l3v5BBwJPOuef6K8N0pa2ISECkW5eOiIj0kQJfRCQgFPgiIgGhwBcRCQgFvohIQCjwRUQCQoEvIhIQCnwRkYD4T1DgCI9bQuGtAAAAAElFTkSuQmCC\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "def ser(x):\n",
    "    X = np.ones( (x.size, 2) )\n",
    "    X[:,1] = x\n",
    "    return X    \n",
    "\n",
    "xx = np.linspace(0, 3, 100) \n",
    "\n",
    "X = ser(xold)  \n",
    "b = np.linalg.pinv(X).dot(yold)\n",
    "yhat = ser(xx).dot(b) \n",
    "plt.plot(xx, yhat, label='w/o outlier'); \n",
    "\n",
    "X = ser(x)  \n",
    "b = np.linalg.pinv(X).dot(y)\n",
    "yhat = ser(xx).dot(b) \n",
    "plt.plot(xx, yhat, label='w/ outlier');  \n",
    "    \n",
    "plt.plot(x[:9],y[:9],'bx');\n",
    "plt.plot(2.5,20,'ro');\n",
    "plt.legend();\n",
    "plt.show();"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.7"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
